<?php
	use ampleharvest\cConfig;
	use \ampleharvest\permissions;
	
	require_once(dirname(dirname(dirname(__FILE__)))) . "/config/cConfig.php";
	
	
	$webConfig = new \ampleharvest\cConfig();
	//require_once $webConfig->C_STR_AMPLEHARVEST_CODE . "/classes/User_Manager/cUserValidation.php";
	//require_once $webConfig->C_STR_AMPLEHARVEST_CODE . "/config/cPermissions.php";

	//Require Login
	//$obj_UserValidation = new cUserValidation();
	// Check Login Status
	//$obj_UserValidation->require_Login(true);
?>


<html>
	<head>
		<title><?php print($webConfig->C_STR_TITLE)?></title>	
		
	</head>
	<body >
		<div id="loading-mask"></div> 
   		<div id="loading" > 
   			<div class="title">
   				<?php print($webConfig->C_STR_TITLE)?>
   			</div>
	        <div class="body"> 
				<div  class="icon">
				</div>
	            <div class="msg" id="loading-msg">Loading styles and images...</div> 
	        </div> 
	    </div> 
	    <link rel="stylesheet" type="text/css" href="<?php print($webConfig->C_STR_EXT4_PATH);?>/resources/css/ext-all.css">
		<link rel="stylesheet" type="text/css" href="<?php print($webConfig->C_STR_CSS_PATH);?>/layout.php" />
		<link rel="stylesheet" type="text/css" href="<?php print($webConfig->C_STR_CSS_PATH);?>/icons.php" />
		<link rel="stylesheet" type="text/css" href="<?php print($webConfig->C_STR_CSS_PATH);?>/classification.css" />
	    
	    <script type="text/javascript">
	    	document.getElementById('loading-msg').innerHTML = 'Loading Core API...';
	    </script> 
	    <script type="text/javascript" src="<?php print($webConfig->C_STR_EXT4_PATH);?>/ext-all.js"></script>
		
	    <script type="text/javascript">
	    	document.getElementById('loading-msg').innerHTML = 'Setting up <?php print($webConfig->C_STR_TITLE)?> ...';
	    </script> 
		
		
		<script language="javascript">

			Ext.onReady(Setup);
	
			function Setup()
			{
				//this.m_obj_Mask.show();
				Ext.Ajax.request(
				{
					url			: '<?php print($webConfig->C_STR_EXTERNAL_PATH) ?>/rest/data/data.php',
					method		: 'GET',
					params		:
					{
						id	: '<?php print($_GET['id']); ?>',
					},
					success		: function(response)
					{
						try
						{
							this.jsonObject = Ext.decode(response.responseText);
							if (this.jsonObject)
							{
								if(this.jsonObject.content)
								{
									var classification = '<div align=center>'+this.jsonObject.classification+'</div>';
									var page = classification+'<hr/>'+this.jsonObject.content+'<hr/>'+classification;
									Ext.getBody().update(page);
									return;
								}
							}
						}
						catch (e)
						{
							Ext.getBody().update('This ID does not exist. Please try again');
							return;
						}
						Ext.getBody().update('The content section is missing in your JSON object');
						
					},
					failure		: function(obj_Response)
					{
						Ext.getBody().update('There was an error contacting the server');
					},
					scope		: this
				});
			}
		</script>
	</body>
</html>
